package com.webserver.controller;

import com.webserver.http.HttpRequest;
import com.webserver.http.HttpResponse;
import qrcode.QRCodeUtil;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class ToolsController {
    /**
     * 生成二维码
     * @param request
     * @param response
     */
    public void createQR(HttpRequest request, HttpResponse response){
        System.out.println("开始生成二维码");
        String content=request.getParameter("content");
        try {

            QRCodeUtil.encode(content,"./V20/2051023.jpg",response.getOutputStream(),true);
            response.setContentType("image/jpeg");
            System.out.println("生成完毕。。。。");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(content);
        System.out.println("二维码生成结束");
    }
}
